add class to body class wordpress

37

add class to body class wordpress -

add_filter( 'body_class', 'custom_class' );
function custom_class( $classes ) {
    if ( is_page_template( 'page-example.php' ) ) {
        $classes[] = 'example';
    }
    return $classes;
}

add class to body class wordpress -

<body <?php body_class( 'class-name' ); ?>>

Comments

Submit
0 Comments